/*    */ package com.cr.framework.manager;
/*    */ 
/*    */ import com.cr.framework.shiro.web.session.SpringSessionValidationScheduler;
/*    */ import javax.annotation.PreDestroy;
/*    */ import net.sf.ehcache.CacheManager;
/*    */ import org.apache.shiro.cache.ehcache.EhCacheManager;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Component;
/*    */ 
/*    */ @Component
/*    */ public class ShutdownManager {
/* 20 */   private static final Logger logger = LoggerFactory.getLogger("sys-user");
/*    */   
/*    */   @Autowired(required = false)
/*    */   private SpringSessionValidationScheduler springSessionValidationScheduler;
/*    */   
/*    */   @Autowired(required = false)
/*    */   private EhCacheManager ehCacheManager;
/*    */   
/*    */   @PreDestroy
/*    */   public void destroy() {
/* 31 */     shutdownSpringSessionValidationScheduler();
/* 32 */     shutdownAsyncManager();
/* 33 */     shutdownEhCacheManager();
/*    */   }
/*    */   
/*    */   private void shutdownSpringSessionValidationScheduler() {
/* 41 */     if (this.springSessionValidationScheduler != null && this.springSessionValidationScheduler.isEnabled())
/*    */       try {
/* 45 */         logger.info("====关闭会话验证任务====");
/* 46 */         this.springSessionValidationScheduler.disableSessionValidation();
/* 48 */       } catch (Exception e) {
/* 50 */         logger.error(e.getMessage(), e);
/*    */       }  
/*    */   }
/*    */   
/*    */   private void shutdownAsyncManager() {
/*    */     try {
/* 62 */       logger.info("====关闭后台任务任务线程池====");
/* 63 */       AsyncManager.me().shutdown();
/* 65 */     } catch (Exception e) {
/* 67 */       logger.error(e.getMessage(), e);
/*    */     } 
/*    */   }
/*    */   
/*    */   private void shutdownEhCacheManager() {
/*    */     try {
/* 75 */       logger.info("====关闭缓存====");
/* 76 */       if (this.ehCacheManager != null) {
/* 78 */         CacheManager cacheManager = this.ehCacheManager.getCacheManager();
/* 79 */         cacheManager.shutdown();
/*    */       } 
/* 82 */     } catch (Exception e) {
/* 84 */       logger.error(e.getMessage(), e);
/*    */     } 
/*    */   }
/*    */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-framework-4.7.0.jar!\com\cr\framework\manager\ShutdownManager.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */